package br.com.kliptus.model.bean;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.maverick.bean.EntityBean;

@Entity
@Table(name = "customer")
public class CustomerJB extends EntityBean {

	private static final long serialVersionUID = 1L;
	
	private EntityJB entity;
	
	private StatusJB status;
	
	private List<ServiceOrderJB> serviceOrderList;

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
	public Long getId() {
		return id;
	}

	@OneToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="entity_id")
	public EntityJB getEntity() {
		return entity;
	}

	public void setEntity(EntityJB entity) {
		this.entity = entity;
	}

	@ManyToOne
	@JoinColumn(name = "status_id", referencedColumnName = "id")
	public StatusJB getStatus() {
		return status;
	}

	public void setStatus(StatusJB status) {
		this.status = status;
	}	
	
	@SuppressWarnings("deprecation")
	@OneToMany(mappedBy="customer", fetch = FetchType.LAZY)
	@Cascade(value = {
			org.hibernate.annotations.CascadeType.ALL, 
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
	public List<ServiceOrderJB> getServiceOrderList() {
		return serviceOrderList;
	}

	public void setServiceOrderList(List<ServiceOrderJB> serviceOrderList) {
		this.serviceOrderList = serviceOrderList;
	}

}
